package hotLeetcode;

import java.util.Arrays;

public class H300Leetcode {

    //用暴力太难了  下面是错误版本
    public static int lengthOfLIS1(int[] nums) {
        int len = nums.length;
        int count = 0;
        for (int i = 0; i < len; i++) {
            int countTemp = 0;
            int temp = nums[i];
            for (int j = i + 1; j < len; j++) {
                if (temp < nums[j]) {
                    temp = nums[j];
                    countTemp++;
                }
            }
            count = Math.max(count, countTemp);
        }

        return count;

    }

    //dp方式
    public static int lengthOfLIS(int[] nums) {
        int len = nums.length;
        if (len == 0) return 0;
        int[] dp = new int[len];
        Arrays.fill(dp, 1);
        int maxLen = 1;
        for (int i = 1; i < len; i++) {
            for (int j = 0; j < i; j++) {
                if (nums[i] > nums[j]) {
                    dp[i] = Math.max(dp[j] + 1, dp[i]);
                }

            }
            maxLen = Math.max(dp[i], maxLen);
        }

        return maxLen;


    }



    public static void main(String[] args) {
        int[] nums = {0,1,0,3,2,3};
        System.out.println(lengthOfLIS(nums));

    }
}
